package com.gxa.www.cl.mapper;

import com.gxa.www.cl.domain.entity.Supplier;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface SupplierMapper {

    @Select("SELECT * FROM 供应商信息表")
    List<Map<String, Object>> getSuppliers();

    @Delete("DELETE FROM 供应商信息表 WHERE id = #{id}")
    void deleteSupplier(Long id);

    // 修改: 确保插入语句包含status字段
    @Insert("INSERT INTO 供应商信息表 (mingcheng, dizhi, lianxiren, dianhua, youbian, chuanzhen, youxiang, status) VALUES (#{mingcheng}, #{dizhi}, #{lianxiren}, #{dianhua}, #{youbian}, #{chuanzhen}, #{youxiang}, #{status})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertSupplier(Supplier supplier);

    @Select("SELECT MAX(id) FROM 供应商信息表")
    Long getMaxId();

    @Select("SELECT * FROM 供应商信息表 WHERE mingcheng = #{mingcheng} AND dizhi = #{dizhi} AND lianxiren = #{lianxiren} AND dianhua = #{dianhua} AND youbian = #{youbian} AND chuanzhen = #{chuanzhen} AND youxiang = #{youxiang} AND status = #{status}")
    Supplier selectSupplierByFields(Supplier supplier);
}